<?php
/**
 * @file login.php
 * @author LD
 * @package kbao
 * @desc 
 *   安全密码验证,用户登录...
 */
if(!defined('ACCOUNT_INIT'))
	exit('Access Denied!');

/* 定义全局变量 */
global $gLD;

/* 未设置密码,直接进入交易 */
if ( !Appleseed::isSetPasswd($gLD['user_id']) ){
	$_SESSION['account_dkb']['dkb_uin'] = $gLD['user_id'];
	$_SESSION['account_dkb']['dkb_pass'] = -1;
	header("LOCATION:?black%20hole={$gLD['BlackHole']}&sessionKey={$gLD['sessionKey']}&uin={$gLD['user_id']}&module=aa");
	//require_once 'aa.php';
	exit;
}else {
	/* -1未设置,1设置 安全密码 */
	$_SESSION['account_dkb']['dkb_pass'] = 1;
}

/**
 * 清空用户登陆验证session值
 */
$_SESSION['account_dkb']['dkb_uin'] = null;

$action = check($_POST['action']);
$password = check($_POST['pswd']);
$user_id = check($_POST['user_id']);

if ( $action == 'login' and !empty($password) ){
	if ( strlen($password) != 8 ){
		$gLD['msg'] = "密码必须为8位英文或数字字符！";
	}else {
		$re = Appleseed::chkBurzaLogin($user_id, $password);
		if ($re == '1'){ //密码验证成功...
			$_SESSION['account_dkb']['dkb_uin'] = $user_id;
			header("LOCATION:?black%20hole={$gLD['BlackHole']}&sessionKey={$gLD['sessionKey']}&uin={$gLD['user_id']}&module=aa");
			exit;
		}else {
			$gLD['msg'] = "密码错误！";
		}
	}
}
	//载入视图模版文件
require_once 'view/Vlogin.php';
?>